package com.ehotting.mqbd.core.mq.consumer.action;

import com.ehotting.mqbd.api.bean.MQDataAble;
import com.ehotting.mqbd.api.bean.MqApplicationContext;
import com.ehotting.mqbd.api.enums.DirectionEnum;
import com.ehotting.mqbd.api.enums.MQDataPushModelEnum;
import com.ehotting.mqbd.api.enums.TopicEnum;
import com.ehotting.mqbd.core.logger.MqMsgLogger;
import com.ehotting.mqbd.core.manager.ModuleManager;
import com.ehotting.mqbd.core.mq.consumer.ClientMQDataHandlerAble;
import com.ehotting.mqbd.core.sync.MqSyncFutureMapHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class CustomConsumerResponseAction extends ConsumerResponseAction {

    private static final Logger logger = LoggerFactory.getLogger(CustomConsumerResponseAction.class);

    protected ClientMQDataHandlerAble clientMQDataHandler;

    public CustomConsumerResponseAction(MqSyncFutureMapHelper<MQDataAble> mqSyncFutureMapHelper,
                                         MqApplicationContext mqApplicationContext,
                                         TopicEnum topic,
                                         DirectionEnum direction,
                                         ModuleManager moduleManager, MqMsgLogger mqMsgLogger,
                                        ClientMQDataHandlerAble clientMQDataHandler) {
        super(mqSyncFutureMapHelper, mqApplicationContext, topic, direction, moduleManager,mqMsgLogger);
        this.clientMQDataHandler = clientMQDataHandler;
    }

    public CustomConsumerResponseAction(MqSyncFutureMapHelper<MQDataAble> mqSyncFutureMapHelper,
                                         MqApplicationContext mqApplicationContext,
                                         TopicEnum topic,
                                         DirectionEnum direction,
                                         String nodeIp,
                                         ModuleManager moduleManager, MqMsgLogger mqMsgLogger,
                                        ClientMQDataHandlerAble clientMQDataHandler) {
        super(mqSyncFutureMapHelper, mqApplicationContext, topic, direction, nodeIp, moduleManager,mqMsgLogger);
        this.clientMQDataHandler = clientMQDataHandler;
    }


    @Override
    public void extInvoke(MQDataAble data) {
        if(data.getPushModel() != MQDataPushModelEnum.HTTP_PUSH){
            clientMQDataHandler.invoke(data);
        }
    }


}
